<?php
declare (strict_types = 1);

namespace app\api\validate;

use think\Validate;

class Course extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'name' => 'require|unique:course',
        'category_id' => 'require|number',
        'introduce' => 'require',
        'price' => 'require',
        'teacher_id' => 'require|number',
        'type' => 'require',
        'start_time' => 'require',
        'over_time' => 'require',
        'on_sale' => 'require',
        'status' => 'require',
        'logo' => 'require|fileExt:png,jpeg,jpg',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'name.require' => '课程名称必填',
        'name.unique' => '课程名称不能重复',
        'category_id.require' => '分类id必填',
        'category_id.number' => '分类只能是数字',
        'introduce.require' => '课程简介必填',
        'price.require' => '课程价格必填',
        'teacher_id.require' => '授课讲师必填',
        'type.require' => '课程类型必填',
        'start_time.require' => '课程开始时间必填',
        'over_time.require' => '课程结束时间必填',
        'on_sale.require' => '课程上下架必填',
        'status.require' => '课程状态必填',
        'logo.require' => '课程封面必填',
        'logo.fileExt' => '课程封面只能是png',
    ];
}
